﻿<table cellspacing="0px" style="margin:0;">
    <tr>
        <td width="70px">
            <input id="FGoodItemID" name="FGoodItemID" class="mini-buttonedit" style="width:70px;" 
                onbuttonclick="getGoodItem('')" onvaluechanged ="getGoodValueChanged" selectOnFocus="true" />
        </td>
        <td width="126px">
            <input id="FGoodName" name="FGoodName" class="mini-textbox" style="width:126px;" 
                enabled = "false"  align="left" readonly="readonly"/>
        </td>
    </tr>
</table>

<script>
    ///增加用户组,打开GetItemID.js的
    function getGoodItem(mSearchKey) {
        var json = "[{";
        mini.open({
            url: "../GetItem/GetGoodInfo",
            title: "商品选择", width: 850, height: 510,
            onload: function () {
                var iframe = this.getIFrameEl();
                var data = { action: "new", sSearchKey: mSearchKey };
                iframe.contentWindow.SetData(data);//打开GetItemID.js的SetData
            },
            ondestroy: function (action) {
                if (action.length > 0) {
                    mini.get("FGoodItemID").setValue(action[0].FItemID);
                    mini.get("FGoodItemID").setText(action[0].FNumber);
                    mini.get("FGoodName").setValue(action[0].FName);
                }
                else {
                    mini.get("FGoodItemID").setValue('');
                    mini.get("FGoodItemID").setText('');
                    mini.get("FGoodName").setValue('');
                }
            }
        });
    }

    function getGoodValueChanged() {
        var sSearchKey = mini.get("FGoodItemID").getText();
        var mAppID = parent.window.getSystemAppID();
        if (sSearchKey == "") {
            mini.get("FGoodName").setValue("");
            return;
        }
        var json = "[{";
        json = json + "'FClassID':" + "'0',";
        json = json + "'FBillType':" + "'0',";
        json = json + "'FSupplierID':" + "'-1',";
        json = json + "'FNumber':" + "'" + sSearchKey + "',";
        json = json + "'FName':'" + "" + "',";
        json = json + "'FStockID':'0',";
        json = json + "'FObjectID':'0',";
        json = json + "'FSystemAppID':'" + parent.window.getSystemAppID() + "'}]";
        $.post("../Bill/GetBillGoodss", { datajson: json }, function (text) {
            var sdata = mini.decode(text);
            if (sdata.data.length == 1) {
                mini.get("FGoodItemID").setValue(sdata.data[0].FItemID);
                mini.get("FGoodItemID").setText(sdata.data[0].FNumber);
                mini.get("FGoodName").setValue(sdata.data[0].FName);
            }
            else {
                getGoodItem(sSearchKey);
            }
        });
    }</script>